package com.truesai.entities.customer;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.dto.OrganType;
/**
 * 供应商详细信息<br/>
 * 需求分析:<br/>
 * <strong>唯一性:</strong>供应商名称.本来想做成一个代码组类型,但考虑有联系人名称和电话号码等信息.就做成了一个实体.<br/>
 * 
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = Provider.ALL, query = "Select p from Provider p"),
        @NamedQuery(name = Provider.BY_NAME, query = "Select p from Provider p where p.name = :name"),
        @NamedQuery(name = Provider.BY_ID, query = "Select p from Provider p where p.id = :id") })
@Table(name = "Customers")
public class Provider {
	public static final String ALL = "Provider.all";

    public static final String BY_NAME = "Provider.byName";

    public static final String BY_ID = "Provider.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**供应商名称*/
    @Column(nullable = false)
    private String name;
    
    /**供应商单位类型*/
    @Column
    @Enumerated(EnumType.ORDINAL)
    private OrganType organType;
    
    /**地址*/
    @Column
    private String address;
    
    /**联系人电话（手机）*/
    @Column
    private String cellphone;
    
    /**联系电话（座机）*/
    @Column
    private String telephone;
    
    /**交易次数*/
    @Column
    private Integer spendTimes;
    
    /**总消费*/
    @Column(scale=2)
    private BigDecimal totalSpend;
    
    /**平均每次交易额*/
    @Column(scale=2)
    private BigDecimal spendAvg;
    
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**@see #name  */
	public String getName() {
		return name;
	}

	/**@see #name  */
	public void setName(String name) {
		this.name = name;
	}

	/**@see #address  */
	public String getAddress() {
		return address;
	}

	/**@see #address  */
	public void setAddress(String address) {
		this.address = address;
	}

	/**@see #cellphone  */
	public String getCellphone() {
		return cellphone;
	}

	/**@see #cellphone  */
	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}

	/**@see #telephone  */
	public String getTelephone() {
		return telephone;
	}

	/**@see #telephone  */
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	/**@see #spendTimes  */
	public Integer getSpendTimes() {
		return spendTimes;
	}

	/**@see #spendTimes  */
	public void setSpendTimes(Integer spendTimes) {
		this.spendTimes = spendTimes;
	}

	/**@see #totalSpend  */
	public BigDecimal getTotalSpend() {
		return totalSpend;
	}

	/**@see #totalSpend  */
	public void setTotalSpend(BigDecimal totalSpend) {
		this.totalSpend = totalSpend;
	}

	/**@see #spendAvg  */
	public BigDecimal getSpendAvg() {
		return spendAvg;
	}

	/**@see #spendAvg  */
	public void setSpendAvg(BigDecimal spendAvg) {
		this.spendAvg = spendAvg;
	}
	
	/**@see #organType  */
	public OrganType getOrganType() {
		return organType;
	}
	
	/**@see #organType  */
	public void setOrganType(OrganType organType) {
		this.organType = organType;
	}
	
    @Override
    public String toString() {
    	return name;
    }

	public Provider() { }
    
    public Provider(String name, OrganType organType, String address,
    		String cellphone, String telephone, Integer spendTimes,
    		BigDecimal totalSpend, BigDecimal spendAvg) {
    	this.name = name;
    	this.organType = organType;
    	this.address = address;
    	this.cellphone = cellphone;
    	this.telephone = telephone;
    	this.spendTimes = spendTimes;
    	this.totalSpend = totalSpend;
    	this.spendAvg = spendAvg;
    }
}
